﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="../../../Scripts/easyUI145/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <script src="../../../Scripts/easyUI145/jquery.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/easyUI145/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../../Comm/JScript.js" type="text/javascript"></script>
    <script src="../../../Scripts/CommonUnite.js" type="text/javascript"></script>
    <script src="../../../Scripts/EasyUIUtility.js" type="text/javascript"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../../Comm/Gener.js" type="text/javascript"></script>
    <!-- 自己的系统风格统一. -->
    <link href="../../../Style/skin/adminfont/iconfont.css" rel="stylesheet" />
    <link href="../../../Style/skin/css/Default.css" rel="stylesheet" />
    <!-- 自己的系统风格统一end -->
    <script src="DDLBar.js" type="text/javascript"></script>
    <script src="../../CCFlowEnum.js" type="text/javascript"></script>
    <style>
        body {
            padding: 15px !important;
            background: #f5f5f5;
        }
    </style>
    <script type="text/javascript">

        var nodeFrmID = "";
        var nodeID = GetQueryString("FK_Node");
        $(function () {

            InitBar(FormSlnType.RefOneFrmTree);

            var html = "";
            //获取节点属性
            var nodeID = GetQueryString("FK_Node");
            var node = new Entity("BP.WF.Node", nodeID);
            //绑定表单类别.
            var ensFrmTree = "BP.Sys.FrmTrees";

            var webUser = new WebUser();
            if (webUser.CCBPMRunModel == 2)
                ensFrmTree = "BP.Cloud.FrmTrees";

            /* var frmTrees = new Entities(ensFrmTree);

             frmTrees.RetrieveAll();

             if (node.FormType == FormSlnType.RefOneFrmTree) {
                 GenerBindDDL("DDL_FrmTree", frmTrees, "No", "Name", node.RefOneFrmTreeType);
             } else {
                 GenerBindDDL("DDL_FrmTree", frmTrees, "No", "Name", node.FormUrl);
             }*/

            //根据表单类别的默认值，初始加载默认的表单
            /* var sortNo = $("#DDL_FrmTree").val();

             if (sortNo != null && sortNo != "") {
                 //获取表单库中的所有表单
                 var frms = new Entities("BP.Sys.MapDatas");
                 frms.Retrieve("FK_FormTree", sortNo);
                 //绑定表单
                 GenerBindDDL("DDL_RefOneFrmTree", frms, "No", "Name", node.NodeFrmID);
             }*/
            nodeFrmID = node.NodeFrmID;

            //表单库的表单.
            if (node.FormType == FormSlnType.RefOneFrmTree) {
                var frmNode = new Entity("BP.WF.Template.FrmNode");
                frmNode.MyPK = node.NodeFrmID + "_" + node.NodeID + "_" + node.FK_Flow;
                var i = frmNode.RetrieveFromDBSources();

                if (i == 1) {
                    var html = ""; // "<a href=\"javascript:EditFrmNode('" + frmNode.MyPK + "')\" >编辑关联的表单属性</a>  - <a href=\"javascript:SetAllNodeFrmUseThisSln()\">设置该流程所有的节点都采用此表单方案</a>";

                    html += "<li><a href=\"javascript:EditFrmNode('" + frmNode.MyPK + "')\" >编辑关联的表单属性</a></li>";
                    html += "<li><a href=\"javascript:SetAllNodeFrmUseThisSln()\">设置该流程所有的节点都采用此表单方案</a></li>";

                    $("#Div_RefOneFrmTree").html(html);
                }
            }

            var frm = new Entity("BP.Sys.MapData", nodeFrmID);

            //设置已经选定的表单库表单.
            var html = "<b>" + node.NodeFrmID + ":" + frm.Name + ",存储表:" + frm.PTable + "</b>";
            var flow = new Entity("BP.WF.Flow", node.FK_Flow);

            if (flow.PTable != frm.PTable)
                html += "<br/><a href=\"javascript:SetFlowPTable('" + node.FK_Flow + "','" + frm.PTable + "')\" >您绑定的表单库的表单与当前流程的业务表单不一致，我们建议您设置为一致.</a>";

            $("#MyFrm").html(html);

        });

        //设置流程业务表与表单的业务表一致.
        function SetFlowPTable(flowNo, ptable) {
            var msg = "";
            msg += "警告:如果您执行该操作，将会有如下问题.";
            msg += "\t\n 1.系统将会扩展一些流程系统字段比如:Title,Starter, WFState,BillNo 等加到表:" + ptable + "里面去.";
            msg += "\t\n 2.如果该表单上需要这些字段,就可以直接使用.";
            msg += "\t\n 3.比如:您需要增加一个自动编号列就可以使用BillNo来完成.";
            msg += "\t\n 4.在处理业务过程中，不必要关联流程业务表NDxxxRpt来管理流程状态等字段信息.";
            if (confirm(msg) == false)
                return;

            var flow = new Entity("BP.WF.Flow", flowNo);
            flow.PTable = ptable;
            flow.Update();
            flow.DoMethodReturnString("CheckRpt");
            alert('系统已经设置成功.');
            window.location.href = window.location.href;
            return;
        }

        function EditFrmNode(mypk) {

            var url = '../../../Comm/En.htm?EnName=BP.WF.Template.FrmNodeExt&MyPK=' + mypk;
            window.open(url);
            return;

            OpenEasyUiDialog(url, "eudlgframe", '编辑', 900, 500, "icon-edit", true, null, null, null, function () {
                window.location.href = window.location.href;
            });
        }

        //设置联动
        function change() {

            //根据表单类别的默认值，初始加载默认的表单
            var sortNo = $("#DDL_FrmTree").val();

            //获取表单库中的所有表单
            var frms = new Entities("BP.Sys.MapDatas");
            frms.Retrieve("FK_FormTree", sortNo);

            //绑定表单
            GenerBindDDL("DDL_RefOneFrmTree", frms, "No", "Name", nodeFrmID);
        }

        function Save() {

            //判断是否已经绑定了表单
            var nodeID = GetQueryString("FK_Node");
            var node = new Entities("BP.WF.Nodes");
            node.Retrieve("NodeID", nodeID);
            if (node[0].NodeFrmID == "") {
                alert('请选择一个表单');
                return;
            }
            alert("保存成功.");

        }

        ///设置该流程的所有节点都是用该方案。
        function SetAllNodeFrmUseThisSln() {

            if (confirm('您确定要设置吗？') == false)
                return;

            var nodeID = GetQueryString("FK_Node");
            var currNode = new Entity("BP.WF.Node", nodeID);

            if (currNode.NodeFrmID == "") {
                alert('错误：您需要为该节点设置表单.');
                return;
            }

            $("#msg").html("正在执行请稍候...");

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_AttrNode_FrmSln");
            handler.AddPara("FK_Node", GetQueryString("FK_Node"));
            var data = handler.DoMethodReturnString("RefOneFrmTree_SetAllNodeFrmUseThisSln");

            alert('设置成功,正在转入批量编辑页面.');
            BatchEdit();

        }

        //节点表单组件属性.
        function SetFrm() {
            var nodeID = GetQueryString("FK_Node");
            var url = "11.RefOneFrmTreeFrms.htm?NodeID=" + nodeID;
            OpenEasyUiDialogExt(url, '选择要绑定的表单', 800, 450, false);
        }
        function BatchEdit() {
            var url = "BatchEditSln.htm?NodeID=" + nodeID;
            window.location.href = url;

        }
    </script>
</head>
<body>

    <div id="bar"> </div>
    <fieldset id="help">
        <legend id="help">选择表单</legend>
        <ul>
            <!--<li>表单类别：<select id="DDL_FrmTree" name="DDL_FrmTree" onchange="change()"> </select> </li>
            <li>表单:  <select id="DDL_RefOneFrmTree" name="DDL_RefOneFrmTree"> </select> </li>
                -->
            <li> <b>已经选择的表单:</b> <font color="green"> <div id="MyFrm"></div></font> </li>
            <li> <button onclick="SetFrm()" id="Btn_Setting"> <img style="width:14px; height:14px;" src="../../../Img/Btn//Setting.png" />  设置表单 </button>  </li>

            <li><font color="green"><b>不成文的开发规范</b></font></li>
            <li>1.设置的表单所有的字段与元素是只读的,并且字段不设置动态的默认值, 比如@WebUser.* 。</li>
            <li>2.使用下面的设置字段权限设置[为该表单的元素设置权限],然后执行批量设置. </li>
            <li>3.一般来说，开始节点设置为自定义方案，其他节点设置为只读方案. </li>
            <li>4.在批量设置里，使用不同的签批组件对应不同的节点. </li>

            <li>5.<font color="green">我们建议您绑定的表单与流程业务表的名称相同，如果您需要单据编号，在绑定的表单里增加一个BillNo字段即可。 </font></li>

        </ul>

    </fieldset>

    <fieldset>
        <legend>设置字段权限</legend>

        <ul>
            <li>为该表单的元素设置权限 - <div id="Div_RefOneFrmTree">   </div> </li>
            <li><a href="javascript:BatchEdit()">批量设置</a> </li>
        </ul>

        <div id="msg"></div>

    </fieldset>

    <!--<fieldset>
        <legend>其他节点</legend>
        <div id="sln"></div>
    </fieldset>-->



    <fieldset>
        <legend id="help">说明</legend>
        <ul>
            <li>表单库里选择一个表单绑定到当前节点上.</li>
            <li>该表单的工作方式与内置表单工作模式一致.</li>
        </ul>
    </fieldset>


</body>
</html>
